<%@page import="com.wed.db.ConnectDB"%>
<%@page import="com.wed.db.SanPham"%>
<%@page import="com.wed.db.TacGia"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<link rel="stylesheet" href="${pageContext.request.contextPath}/Style.css" type="text/css" charset="utf-8" />	
</head>
<script language="JavaScript">
	function KiemTraMS() {
		if (a.masach.value.length > 10)
			alert("Báº¡n da go qua so ki tu cho phep !");
	}
	function CheckSo(evt)
	{
		var charCode=(evt.which)?evt.which:event.keyCode
				if(charCode>31&& (charCode<48||charCode>57))
					return false;
		return true;
	}

	function KiemTra()

	{
		//if (masach.value.length > 200) alert("Báº¡n Ä‘Ã£ gÃµ qÃºa sá»‘ kÃ½ tá»± cho phÃ©p !");

		var err = "";
		if (a.masach.value == "") {
			err += " ++masach++";

		}

		if (a.tensach.value == "") {
			err += " ++tensach++";

		}
		if (a.theloai.value == "") {
			err += " ++theloai++";

		}
		if (a.tacgia.value == "") {
			err += " ++tacgia++";

		}
		if (a.noidung.value == "") {
			err += " ++noidung++";

		}
		if (a.gianhap.value == "") {
			err += " ++gia nhap++";

		}
		if (a.giaban.value == "") {
			err += " ++gia ban++";

		}
		if (err != "") {
			alert("ban khong duoc bo" + err);
		}

	}
</script>



<body>
<%ArrayList<TacGia>  tg = new ConnectDB().getAllTacGia(); %>
<% SanPham sp = new ConnectDB().getProductByID(Integer.parseInt(request.getParameter("MaSach"))); %>
<div id="page">
			<div id="header">
				
				<a href="index.html" id="logo"></a> <!-- /#logo -->
				
			</div> <!-- /#header -->
			<div id="contents">
			<ul id="navigation">
					<li><a href="TrangChu.jsp">Trang Chủ</a></li>
					<li><a href="#"> Giới Thiệu</a></li>
				<li><a href="#">Hoạt Động</a></li>
					<li class="selected"><a href="ThongTinSach.jsp">Quản Lí</a></li>
					<li><a href="login.jsp">Thoát</a></li>


				</ul>
	<form action="updateServlet" name="a" onsubmit="return kiemtra();" >
			<table width="399"  align="center" cellpadding="5"
			cellspacing="5" bgcolor="#FFFFCC">
			<tr>
				<th colspan="2" scope="col"><font size="5" color="red">CẬP NHẬT THÔNG TIN SÁCH</font></th>
			</tr>
			<tr>
			<tr>
				<td width="131">Mã Sách</td>
				<td width="225"><label for="masach"></label> <input type="text"
					name="MaSach" id="MaSach"value="<%=sp.getMaSach()%>"  onKeyUp="KiemTraMS();"readonly="readonly" /></td>
			</tr>
			<tr>
				<td width="131">Tên Sách</td>
				<td width="225"><label for="tensach"></label> <input
					type="text" name="TenSach" id="TenSach" value="<%=sp.getTenSach()%>"/></td>
			</tr>
			<tr>
				<td width="131">Thể Loại</td>
				<td width="225"><label for="theloai"></label> <input
					type="text" name="TheLoai" id="TheLoai"value="<%=sp.getTheLoai()%>" /></td>
			</tr>
			<tr>
				<td width="131">Tác Giả</td>
				<td width="225"><label for="tacgia"></label> <label><%=sp.getTacGia()%></label> 
					<select name="TacGia">
					 <option value="">-----All-----</option>
                               <%
				 for(TacGia t : tg){
					
				 
				%>
				
                                    <option value="<%=t.getMaTG() %>"><%= t.getTenTG()%></option><% 
					}
					 %>
                            

                            </select></td>
			</tr>
			<tr>
				<td width="131">Nhà Xuất Bản</td>
				<td width="225"><label for="nxb"></label> <input type="text"
					name="NXB" id="NXB"value="<%=sp.getNXB()%>" /></td>
			</tr>
			<tr>
				<td width="131">Giá Nhập</td>
				<td width="225"><label for="gianhap"></label> <input
					type="text" name="GiaNhap" id="GiaNhap"
					onkeydown="return CheckSo(event)" value="<%=sp.getGiaNhap()%>"/></td>
			</tr>
			<tr>
				<td width="131">Giá Bán</td>
				<td width="225"><label for="giaban"></label> <input type="text"
					name="GiaBan" id="GiaBan" onkeydown="return CheckSo(event)" value="<%=sp.getGiaXuat()%>"/></td>
			</tr>
			<% int t=Integer.parseInt(request.getParameter("MaSach"));
			String viewImage = "XemHinhAnh.jsp?MaSach="+t;
			%>
			<tr>
				<td width="131">Hình Ảnh</td>
				<td width="225"><label for="noidung"></label><a href="<%=viewImage%>">Xem ảnh</a></td>
			</tr>
			<tr>
				<td><div align="right"></div></td>
				<td><input type="submit" name="Submit" value="Save;"
					onclick="KiemTra()" /> <input type="reset" name="Submit2"
					value="Huy" /></td>
			</tr>
		</table>
	</form>
</div>
<div id="footer">
				<div id="description">
					<div>
						<a href="index.html" class="logo"></a>
						<span>&copy; Copyright &copy; 2011. <a href="index.html">Company name</a> All rights reserved</span>
					</div>
				
				</div>
				<div class="navigation">
					<a href="TrangChu.html">Trang Chủ</a>|
					<a href="#">Giới Thiệu</a>|
					<a href="ThongTinSach.html">Quản Lí</a>|
					<a href="shop.html">Shop</a>|
					<a href="contact-us.html">Contact Us</a>
				</div>
			</div> <!-- /#footer -->
</body>
</html>